(require 'lisp-unit)
(defpackage :bencoding-tests
  (:use :common-lisp :bencoding :lisp-unit))

(in-package :bencoding-tests)

(define-test unbencode-string
  (assert-equal '("spam" 6) (unbencode-string "4:spam" 0))
  (assert-equal '("qwertyuiopasdfghjklzxcvbnm" 29) (unbencode-string "26:qwertyuiopasdfghjklzxcvbnm" 0))
  (assert-equal '("3:spam" 8) (unbencode-string "6:3:spam" 0)))

(define-test unbencode-integer
  (assert-equal '(42 3) (unbencode-integer "42e" 0)))

(define-test unbencode-list
  (assert-equal '(("spam" 42) 12) (unbencode-list "l4:spami42ee" 1)))

(define-test unbencode-dictionary
  (assert-equal '(("spam" . 42)) (unbencode-dictionary "d4:spami42ee" 1)))